<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>My JSP 'changeTeaForClasses' starting page</title>
		<script type="text/javascript" src="../js/jquery-1.8.0.min.js"></script>
		<script type="text/javascript">
			$(function(){
				var selects = document.getElementsByTagName("select");
				for(var i=0 ; i<selects.length ; i++){
					var select = selects[i];
					var deltid = $(select).attr("deleteTea");
					var deptid = $(select).attr("dept");
					var isPro  = $(select).attr("isPro");
					$.ajax({
						type:"post",
						url:"./teacher!findChangeTeaForDelTeacher.action",
						data:{n:Math.random(),"teacher.id":deltid,"teacher.dept.id":deptid,"teacher.isPro":isPro},
						async:false,
						success:function(msg){
							var arr = eval(msg);
							for(var k=0 ; k<arr.length ; k++){
								var op = document.createElement("option");
								op.value = arr[k].id;
								op.innerHTML = arr[k].name ;
								select.appendChild(op);
							}
						}
					});
				}
			});
			
			function sub(){
				var form1 = document.getElementById("form1");
				form1.submit();
				window.opener.location.reload();
				window.close();
			}
		</script>
	</head>

	<body>
		<s:form theme="simple" action="./teacher!deleteteacher.action" id="form1">
		<div>您所删除的教师:${teaching.name}</div>
		<div>所在部门:${teaching.dept.name}:${teaching.isPro==0?"讲师":"班主任"}</div>
		<p></p>
		<div>以下为${teaching.name}所带班级:</div>
		<div>
			<table border="1" width="50%">
				tid:<input type="text" value="${teaching.id}" name="teacher.id">
				pro:<input type="text" value="${teaching.isPro}" name="teacher.isPro">
				<s:if test="#request.teaching.isPro==0">
					<s:iterator value="#request.teaching.classesesForProTeacher" var="tempC">
						<s:if test="#tempC.isDelete==0">
							<tr>
								<td>
									${tempC.name}
									<input type="text" name="classesids" value="${tempC.id}">
								</td>
								<td>${tempC.term.name}</td>
								<td>
									<select name="teacherids" deleteTea="${teaching.id}" dept="${teaching.dept.id}" isPro="${teaching.isPro}">
										<option>=选择新教师=</option>
									</select>
								</td>
							</tr>
						</s:if>
					</s:iterator>
				</s:if>
				<s:else>
					<s:iterator value="#request.teaching.classesesForHeadTeacher" var="tempC">
						<s:if test="#tempC.isDelete==0">
							<tr>
								<td>
									${tempC.name}
									<input type="text" name="classesids" value="${tempC.id}">
								</td>
								<td>${tempC.term.name}</td>
								<td>
									<select name="teacherids" deleteTea="${teaching.id}" dept="${teaching.dept.id}" isPro="${teaching.isPro}">
										<option>=选择新教师=</option>
									</select>
								</td>
							</tr>
						</s:if>
					</s:iterator>
				</s:else>
			</table>
		</div>
		<div>
			<input type="button" value="确认删除" onclick="sub();"> 
		</div>
		</s:form>
	</body>
</html>
